﻿@model IEnumerable<KRM.Core.vCostsPerProductOption>
<script src="~/js/tabletocsv.js"></script>
<script>
    function updateChanges() {
        App.blockUI($('body'), false);
        $.ajax({
            type: 'POST',
            url: '/products/UpdateChanges',
            success: function (data) {
                $('.productoptionresults').html(data);
                InitDatatable();
                InitTableSelected();
                App.unblockUI($('body'));
                alert("Your Selected Product Option Changes Have Been Updated");
            },
            error: function () {
                App.unblockUI($('body'));
            }
        });
    }
</script>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="fieldset">
            <div class="legend"><span>Results</span></div>
@*            <div class="row-fluid text-right" style="margin-bottom: 10px;">
                <button class="btn btn-info w90" type="button" onclick="ExportCSVWithHead($('.tbody'), 'Table.csv', $('.thead'))">
                    <img src="/img/icon-exel.png" style="max-height: 20px">
                    Export</button>
            </div>*@
            <div class="row-fluid">
                <table class="table table-bordered table-fix krmtable tbl-selected" data-height="200">
                    <thead class="thead">
                        <tr>
                            <th>OnSite</th>
                            <th>DepartmentName</th>
                            <th>ProductID</th>
                            <th>ProductOptionID</th>
                            <th>ProductName</th>
                            <th>ProductOptionText</th>
                            <th class="sugg">SuggestedRetail</th>
                            <th>CurentRetail</th>
                            <th>RetailExVAT</th>
                            <th>Margin£</th>
                            <th>Margin%</th>
                            <th>PartsTrade</th>
                            <th>CarriageCharge</th>
                            <th>PartsCarriage</th>
                            <th>TotalCost</th>
                            <th>Availability</th>
                            <th>OptionDays</th>
                            <th>TotalWeight</th>
                        </tr>
                    </thead>
                    <tbody class="tbody">
                        @foreach (var item in Model)
                        {
                            string bold = "";
                            bold = item.CarriageCharge > 0 ? "font-weight:bold;" : "";
                            <tr onclick="productoptionbreakdowndetail('@item.ProductOptionID')" style="@bold" >
                                <td style="text-align: center;">
                                    @if (item.OnSite == "True")
                                    {
                                        <img src="/img/green.png" width="20px" />
                                    }
                                    else
                                    {
                                        <img src="/img/red.png" width="20px" />
                                    }
                                </td>
                                <td>@item.DepartmentName</td>
                                <td>@item.ProductID</td>
                                <td>@item.ProductOptionID</td>
                                <td>@item.ProductName</td>
                                <td>@item.ProductOptionText</td>
                                <td class="sugg vsugg">@item.SuggestedRetail</td>
                                <td>@item.RetailIncVAT</td>
                                <td>@item.RetailExVAT</td>
                                <td>@item.MarginPound</td>
                                <td>@item.MarginPercentage</td>
                                <td>@item.PartsTrade</td>
                                <td>@item.CarriageCharge</td>
                                <td>@item.PartsCarriage</td>
                                <td>@item.TotalTrade</td>
                                <td>@item.Availability</td>
                                <td>@item.OptionDays</td>
                                <td>@item.TotalWeight</td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@*    <div class="row-fluid text-right">
        <a class="btn btn-primary" onclick="updateChanges()">Update Changes</a>
    </div>*@
</div>